package cn.tannn.cat.file.server.init;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import static cn.tannn.cat.file.sdk.core.local.LocalDirverUtil.getRealIp;
import static cn.tannn.cat.file.sdk.core.local.LocalOperate.SPIRIT;


/**
 * @author tnnn
 * @version V1.0
 * @date 2024/3/26 下午8:53
 */
@Component
@Slf4j
public class CustomConsoleConfig implements CommandLineRunner {

    @Value("${server.port:8080}")
    private int serverPort;

    @Value("${server.servlet.context-path:/}")
    private String serverName;

    /**
     * 冒号
     */
    String COLON = ":";

    @Override
    public void run(String... args) throws Exception {
        try {
            if (SPIRIT.equals(serverName)) {
                serverName = "";
            }
            log.info("\n----------------------------------------------------------\n\t" +
                    "启动成功！apifox文档地址 ： (https://qnjmlsrvao.apifox.cn)\n\t" +
                    "启动成功！swagger地址   ： (http://" + getRealIp() + COLON + serverPort + serverName + "/doc.html" + ")\n\t" +
                    "启动成功！管理端地址     ： (http://" + getRealIp() + COLON + serverPort + serverName + "/admin" + ")\n\t" +
                    "----------------------------------------------------------");
        } catch (Exception ignored) {
        }
    }
}
